﻿<p><table border=1 bordercolor=#808080 cellspacing=0 cellpadding=2 style="margin-left:1.4pt;border-collapse:collapse;border:1">
<tr bgcolor=#e0e0e0 align=center><td>Name</td><td>Info</td><td>Lunch<br>Dinner</td><td>Action</td></tr>

<?php
$dbConn = new mysqli(HOST,USER,PWD,DB);
$rid=  $_SESSION['rid'];

/* prepare statement */
$dbConn->query("SET NAMES 'utf8'");
if ($stmt = $dbConn->prepare("select b.reginfoid, b.cname, b.first_name, b.last_name, b.relationship, b.gender, b.groups, b.pastoral_staff, b.meal1, b.meal2, b.meal3, b.meal4, b.meal5, b.meal6, b.meal7, b.meal8 from registration a, registration_info b where a.rid= ?  and a.rid = b.rid ")) {
    $stmt->bind_param('i', $rid);
    $stmt->execute(); 
    $stmt->bind_result($col1,$col2,$col3,$col4,$col5,$col6,$col7,$col8,$meal1,$meal2,$meal3,$meal4,$meal5,$meal6,$meal7,$meal8);
    $i = 0;
    while ($stmt->fetch()) {
	echo "<form name=f"; printf("%d ",i); echo "action=con_modreginfo.php method=POST>";
	echo "<input type=hidden name=rid value=" . $rid . ">";
	echo "<input type=hidden name=reginfoid value=" . $col1 . ">";
	echo "<tr><td align=right>姓名:<input type=text name=cname size=8 value=" . $col2 . ">";
	echo "<br>First:<input type=text name=first_name size=6 value=" . $col3 . ">";
	echo "<br>Last:<input type=text name=last_name size=6 value=" . $col4 . ">";
	echo "</td><td align=right>Relation:";
	$sel = $col5;
	include("con_sel_relation.php");
	echo "<br>Gender:<input type=text name=gender size=1 value=" . $col6 . ">";
	echo "<br>Group:";
	$sel = $col7;
	include("con_sel_group.php");
	if ($col8) $check="checked "; else $check = "";
	echo "<br>Fulltime Minister:<input type=checkbox " . $check . "name=pastor value=1>";
	echo "</td><td><table border=0 cellspacing=0 cellpadding=0>";
	if ($meal1) $check="checked "; else $check = "";
	echo "<tr><td>7/2</td><td></td><td><input type=checkbox " . $check . "name=meal1 value=1></td></tr>";
	if ($meal2) $check="checked "; else $check = "";
	echo "<tr><td>7/3</td><td><input type=checkbox " . $check . "name=meal2 value=1>";
	if ($meal3) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=meal3 value=1></td></tr>";
	if ($meal4) $check="checked "; else $check = "";
	echo "<tr><td>7/4</td><td><input type=checkbox " . $check . "name=meal4 value=1>";
	if ($meal5) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=meal5 value=1></td></tr>";
	if ($meal6) $check="checked "; else $check = "";
	echo "<tr><td>7/5</td><td><input type=checkbox " . $check . "name=meal6 value=1>";
	if ($meal7) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=meal7 value=1></td></tr>";
	if ($meal8) $check="checked "; else $check = "";
	echo "<tr><td>7/6</td><td><input type=checkbox " . $check . "name=meal8 value=1></td></tr></table>";
	echo "</td><td><input type=submit name=action value=Update>";
	echo " <input type=submit name=action value=Del>";
	echo "</td></tr></form>";
	$i++;
    }
    echo "<form name=fadd action=con_modreginfo.php method=POST>";
    echo "<tr><td align=right>姓名:<input type=text name=cname size=8>";
    echo "<br>First:<input type=text name=first_name size=6>";
    echo "<br>Last:<input type=text name=last_name size=6>";
    echo "</td><td align=right>Relation:";
    include("con_sel_relation.php");
    echo "<br>Gender:<input type=text name=gender size=1>";
    echo "<br>";
    include("con_sel_group.php");
    echo "<br>Fulltime Minister:<input type=checkbox name=pastor value=1>";
    echo "</td><td><table border=0 cellspacing=0 cellpadding=0>";
    echo "<tr><td>7/2</td><td></td><td><input type=checkbox name=meal1 value=1></td></tr>";
    echo "<tr><td>7/3</td><td><input type=checkbox name=meal2 value=1>";
    echo "</td><td><input type=checkbox name=meal3 value=1></td></tr>";
    echo "<tr><td>7/4</td><td><input type=checkbox name=meal4 value=1>";
    echo "</td><td><input type=checkbox name=meal5 value=1></td></tr>";
    echo "<tr><td>7/5</td><td><input type=checkbox name=meal6 value=1>";
    echo "</td><td><input type=checkbox name=meal7 value=1></td></tr>";
    echo "<tr><td>7/6</td><td><input type=checkbox name=meal8 value=1></td></tr></table>";
    echo "</td><td><form action=con_modreginfo.php method=post>";
    echo "<input type=hidden name=rid value=" . $rid . ">";
    echo "<input type=submit name=action value=Add>";
    echo "</td></tr></form>";
    echo "</table></p>";
}
?>
